import pygame,time,random
pygame.init()
screen=pygame.display.set_mode([700,700])
screen.fill([0,255,0])
pygame.display.flip()

fangkuaichange=70
fangkuaikuan=70

cao=[
[10,10],
[2,2,3,2,2,0,0,0,0,0],
[2,2,3,2,2,0,0,0,0,0],
[3,3,3,2,2,0,0,0,0,0],
[2,2,2,2,2,0,0,0,0,0],
[2,2,2,2,2,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0]
]
caoc=([],[0,100,0],[0,0,0],[255,255,255])
def d(screen,cao,caoc,weizhi,daxiao):
    a=cao[0]
    a1=a[1]
    x=0
    y=0
    while x<a1:
        #print(x,y)
        c=cao[x+1][y]
        if c==0:
            y+=1
            if y>a1-1:
                x+=1
                y=0
            #a[1]-=1
            #print(1)
            #if a[1]<1:
             #   a[0]-=1
              #  a[1]+=a1
            continue
        else:
            pygame.draw.rect(screen,caoc[c],[weizhi[0]+y*daxiao[0],weizhi[1]+x*daxiao[1],daxiao[0],daxiao[1]],0)
        pygame.display.flip()
        y+=1
        if y>a1-1:
            x+=1
            y=0
            if x==5:
                pass
        #a[1]-=1
        #print(2)
        #if a[1]<1:
        #    a[0]-=1
        #    a[1]+=a1
"""
def drawtu(cao,x,y,c,daxiao,screen):
    d=True
    z=0
    a=c[z]
    b1=cao[0][0]
    b2=cao[0][1]
    while a>0:
        d=True
        z+=1
        cc=c[z]
        if cc[0]>255 or cc[0]<0:
            d=False
        y1=0
        x1=1
        r=True
        while r:
            rectc=cao[x1][y1]
            if rectc==z:
                if d:
                    pygame.draw.rect(screen,cc,[x+daxiao[0]*(x1-1),y+daxiao[1]*y1,daxiao[0],daxiao[1]],0)
            y1+=1
            if y1+1==b1:
                y1=0
                x1+=1
            if x1==b2:
                r=False
        a-=1

drawtu(cao,200,200,caoc,[10,10],screen)
pygame.display.flip()
"""
r=True
d(screen,cao,caoc,[200,200],[20,20])
while r:
    pygame.draw.rect(screen,[255,0,0],[0,0,30,20],0)
    for event in pygame.event.get():
        if  event.type == pygame.MOUSEBUTTONUP:
            if event.button==1:
                x1,y1=event.pos
                if x1<=30 and x1>0:
                    if y1<=20 and y1>0:
                        pygame.quit()
                        r=False
    if r:
        #drawtu(cao,200,200,caoc,[10,10],screen)
        pygame.display.flip()


"""
pygame.draw.circle(screen, [aaaa,aaaaa,aaaaaa], [a,aa], aaa)
"""